return {
	'hrsh7th/nvim-cmp',
	dependencies = {
		'L3MON4D3/LuaSnip',

		'saadparwaiz1/cmp_luasnip',
		'hrsh7th/cmp-nvim-lsp',
		'hrsh7th/cmp-buffer',
		'hrsh7th/cmp-path',
		'hrsh7th/cmp-cmdline',
	},
	event = "InsertEnter",
	config = function()
		local cmp = require 'cmp'

		local select_prev_item = function(fallback)
			if cmp.visible() then
				cmp.select_prev_item()
			else
				fallback()
			end
		end

		local select_next_item = function(fallback)
			if cmp.visible() then
				cmp.select_next_item()
			else
				fallback()
			end
		end

		local confirm = function(fallback)
			if cmp.visible() and cmp.get_selected_entry() then
				cmp.confirm({
					behavior = cmp.ConfirmBehavior.Replace,
					select = false,
				})
			else
				fallback()
			end
		end

		cmp.setup {
			sources = cmp.config.sources({
				{ name = 'nvim_lsp' },
				{ name = 'luasnip' },
			}, {
				{ name = 'buffer' },
			}),

			--[[
	      Preselects do not (and _should not_) trigger completion, and thus do
	      not play well with <Tab>.
	    ]]
			preselect = cmp.PreselectMode.None,

			mapping = {
				['<CR>'] = confirm,
				['<S-Tab>'] = select_prev_item,
				['<Tab>'] = select_next_item,
				['<C-p>'] = select_prev_item,
				['<C-n>'] = select_next_item,
			},
		}

		local npairs_cmp_loaded, npairs_cmp = pcall(require, 'nvim-autopairs.completion.cmp')
		if npairs_cmp_loaded then
			cmp.event:on('confirm_done', npairs_cmp.on_confirm_done())
		end
	end,
}
